<?php
/*
* @Created by Phpstorm
* @User: Zhangxinlei
* @Date: 
* @Time:
*/

namespace app\admin\controller\admin;

use app\admin\controller\Base;
use think\facade\Cache;
use think\facade\Request;
use think\facade\Db;
use think\facade\View;
use app\common\service\AdminDynamic as S;
use app\common\model\AdminDynamic as M;
class Dynamic extends Base
{
    public function index(){
        
        $dylist = M::getList();
        // halt($dylist);
        $page = $dylist->render();
        
        View::assign(['dylist'=>$dylist]);
        return $this->fetch();
    }
    public function add(){
        if (Request::isAjax()) {
            return $this->getJson(S::goAdd(Request::post()));
        }
        return $this->fetch();
    }

    public function edit($id){
        // halt($id);
        if (Request::isAjax()) {
            return $this->getJson(S::goEdit(Request::post(),$id));
        }
        return $this->fetch('',['model' => M::find($id)]);
    }

    public function remove($id){
        return $this->getJson(S::goRemove($id));
    }
}